package parts3.lesson29;

public class MyThread implements Runnable {
    private int ticket = 20;
    private String title;

    public MyThread(String title) {
        this.title = title;
    }

    //实现简单的一个卖票的功能，20张票，卖光即止
    @Override
    public void run() {
        for (int x = 0; x < 20; x++) {
            if (this.ticket > 0) {
                System.out.println(this.title + "卖票中，ticket=" + this.ticket--);
            }
        }
    }
}
